package com.pinyougou.shop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.pojogroup.Goods;
import com.pinyougou.sellergoods.service.GoodsService;
import entity.MyResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Reference
    private GoodsService goodsService;

    /**
     * 新增商品
     */
    @RequestMapping("/add")
    public MyResult add(@RequestBody Goods goods) {
        //设置商家ID
        goods.getGoods().setSellerId("fauks");
        try {
            goodsService.add(goods);
            return new MyResult(true, "增加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new MyResult(false, "增加失败");
        }
    }
}
